package com.mall507.fivepeaks.activity.mine;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.hzh.frame.comn.callback.HttpCallBack;
import com.hzh.frame.core.HttpFrame.BaseHttp;
import com.hzh.frame.ui.activity.AbsRecyclerViewUI;
import com.hzh.frame.ui.fragment.AbsRecyclerViewFM;
import com.hzh.frame.widget.xdialog.XDialog2Button;
import com.hzh.frame.widget.xrecyclerview.RecyclerViewHolder;
import com.mall507.comn.model.MineCollection;
import com.mall507.comn.model.MineRelease;
import com.mall507.fivepeaks.R;
import com.mall507.fivepeaks.widget.imageview.CircleImageView;
import com.mall507.fivepeaks.widget.imageview.ExpandImageView;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author
 * @version 1.0
 * @date 2019/8/26
 */
@Route(path = "/mine/ReleaseRFM")
public class ReleaseRFM extends AbsRecyclerViewFM<MineRelease> {
    public final int ITEM_TYPE_ZHAOPIN = 0xff04;//招聘
    public final int ITEM_TYPE_QIUZHI = 0xff05;//求职
    public final int ITEM_TYPE_CHUZU = 0xff06;//出租
    public final int ITEM_TYPE_QIUZU = 0xff07;//求租
    public final int ITEM_TYPE_CHUSHOU = 0xff08;//出售
    public final int ITEM_TYPE_QIUGOU = 0xff09;//求购
    public final int ITEM_TYPE_ZHUANRANG = 0xff10;//转让
    public final int ITEM_TYPE_ERSHOU = 0xff11;//二手买卖
    String info_type = "1";
    String type = "1";

    @Override
    public boolean setTitleIsShow() {
        return false;
    }

    public static ReleaseRFM newInstance(int type) {
        ReleaseRFM myFragment = new ReleaseRFM();
        Bundle bundle = new Bundle();
        bundle.putInt("type", type);
        myFragment.setArguments(bundle);
        return myFragment;
    }

    @Override
    protected void bindView(View view) {
        showLoding();
        super.bindView(view);
    }

    @Override
    protected int setLayoutId() {
        return R.layout.fm_rv_mine_release_index;
    }



    @Override
    protected String setHttpPath() {
        return "Me/getRelease";
    }

    @Override
    protected JSONObject setHttpParams() {
        JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return params;
    }

    @Override
    protected List<MineRelease> handleHttpData(JSONObject response) {
        List<MineRelease> list = new ArrayList<>();
        if(200 == response.optInt("code")){
            JSONArray jsonArray=response.optJSONArray("data");
            if (jsonArray != null&&jsonArray.length()>0){
                for(int i=0;i<jsonArray.length();i++){
                    JSONObject object=jsonArray.optJSONObject(i);
                    JSONObject info = jsonArray.optJSONObject(i).optJSONObject("info");
                    MineRelease model=new MineRelease();
                    model.setAreaid(object.optString("areaid"));
                    model.setInfo_type(object.optString("info_type"));
                    model.setType(object.optString("type"));
                    model.setNid(object.optString("id"));
                    model.setStatus_name(object.optString("status_name")); //审核状态

                    model.setTitle(object.optString("title"));
                    model.setAreaname(object.optString("areaname")); //地区名称
                    model.setPosttime(object.optString("posttime"));
                    model.setThumb(object.optString("thumb"));
                    model.setPrice(object.optString("price")); //价格price
                    model.setHead_img(object.optString("head_img")); //求职者头像

                    if(info != null){
                        model.setXinzi(info.optString("xinzi"));
                        model.setRenshu(info.optString("renshu"));
                        model.setGongsi(info.optString("gongsi"));
                        model.setXingbie(info.optString("xingbie"));
                        model.setNianling(info.optString("nianling"));
                        model.setXiaoqu(info.optString("xiaoqu"));
                        model.setShi(info.optString("shi"));
                        model.setTing(info.optString("ting"));
                        model.setWei(info.optString("wei"));
                        model.setLeixing(info.optString("leixing"));
                        model.setMianji(info.optString("mianji"));
                        model.setZhuanranfei(info.optString("zhuanranfei"));
                        model.setZujin(info.optString("zujin"));
                    }
                    list.add(model);
                }
            }
        }
        dismissLoding();
        return list;
    }

    @Override
    protected int setItemViewType(int position) {
        info_type = getAdapter().getDatas().get(position).getInfo_type();
        type = getAdapter().getDatas().get(position).getType();
        if (info_type != null&&type != null){
            if (info_type.equals("1")){
                if (type.equals("1")){
                    return ITEM_TYPE_ZHAOPIN;
                }else if (type.equals("2")){
                    return ITEM_TYPE_QIUZHI;
                }
            }else if (info_type.equals("2")){
                if (type.equals("1")){
                    return ITEM_TYPE_CHUZU;
                }else if (type.equals("2")){
                    return ITEM_TYPE_QIUZU;
                }
            }else if (info_type.equals("3")){
                if (type.equals("1")){
                    return ITEM_TYPE_CHUSHOU;
                }else if (type.equals("2")){
                    return ITEM_TYPE_QIUGOU;
                }
            }else if (info_type.equals("4")){
                return ITEM_TYPE_ZHUANRANG;
            }else if (info_type.equals("5")){
                return ITEM_TYPE_ERSHOU;
            }
        }

        return ITEM_TYPE_ZHAOPIN;
    }

    @Override
    protected int setItemLayoutId(int viewType) {
        if (viewType == ITEM_TYPE_ZHAOPIN){
            return R.layout.item_rv_main_convenient_life_zhao_pin1;
        }else if (viewType == ITEM_TYPE_QIUZHI){
            return R.layout.item_rv_main_convenient_life_qiu_zhi1;
        }else if (viewType == ITEM_TYPE_CHUZU){
            return R.layout.item_rv_main_convenient_life_chu_zu1;
        }else if (viewType == ITEM_TYPE_QIUZU){
            return R.layout.item_rv_main_convenient_life_qiu_zu1;
        }else if (viewType == ITEM_TYPE_CHUSHOU){
            return R.layout.item_rv_main_convenient_life_chu_shou1;
        }else if (viewType == ITEM_TYPE_QIUGOU){
            return R.layout.item_rv_main_convenient_life_qiu_gou1;
        }else if (viewType == ITEM_TYPE_ZHUANRANG){
            return R.layout.item_rv_main_convenient_life_zhuan_rang1;
        }else if (viewType == ITEM_TYPE_ERSHOU){
            return R.layout.item_rv_main_convenient_life_er_shou_mai_mai1;
        }
        return R.layout.item_rv_main_convenient_life_zhao_pin1;
    }

    @Override
    protected void bindItemData(RecyclerViewHolder holder, int position, MineRelease model) {
        holder.setText(R.id.title, model.getTitle());
        switch (getAdapter().getItemViewType(position)) {
            case ITEM_TYPE_ZHAOPIN:
                bindZhaoPin(holder, position, model);
                break;
            case ITEM_TYPE_QIUZHI:
                bindQiuZhi(holder, position, model);
                break;
            case ITEM_TYPE_CHUZU:
                bindChuZu(holder, position, model);
                break;
            case ITEM_TYPE_QIUZU:
                bindQiuZu(holder, position, model);
                break;
            case ITEM_TYPE_CHUSHOU:
                bindChuShou(holder, position, model);
                break;
            case ITEM_TYPE_QIUGOU:
                bindQiuGou(holder, position, model);
                break;
            case ITEM_TYPE_ZHUANRANG:
                bindZhuanRang(holder, position, model);
                break;
            case ITEM_TYPE_ERSHOU:
                bindErShou(holder, position, model);
                break;
        }
    }

    public void bindZhaoPin(RecyclerViewHolder holder, final int position, final MineRelease model) {
        ((ExpandImageView) holder.getView(R.id.icon)).setImageURI(model.getThumb());
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        holder.setText(R.id.title, model.getTitle());
        holder.setText(R.id.money, model.getXinzi());
        holder.setText(R.id.desc, model.getAreaid() + "|招聘" + model.getRenshu() + "人");
        holder.setText(R.id.time, model.getPosttime());
        holder.setText(R.id.address, model.getGongsi());
        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/main/MainZhaoPinInfoUI")
                        .withString("id", model.getNid())
                        .navigation();
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                    @Override
                    public void onSuccess(JSONObject response) {
                        super.onSuccess(response);
                        if (response.optInt("code") == 200){
                            onRefresh();
                        }else {
                            alert(response.optString("message"));
                        }
                    }
                });
            }
        });
    }

    public void bindQiuZhi(RecyclerViewHolder holder, int position, final MineRelease model) {
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        holder.setText(R.id.title, model.getTitle());
        String xingbie = model.getXingbie().equals("1")?"男":"女";
        holder.setText(R.id.desc, model.getAreaid() + "|" + xingbie + "|" + model.getNianling());
        holder.setText(R.id.time, model.getPosttime());

        ((CircleImageView) holder.getView(R.id.icon)).setImageURI(model.getHead_img());
        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/main/MainQiuZhiInfoUI").withString("id", model.getNid()).navigation();
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                    @Override
                    public void onSuccess(JSONObject response) {
                        super.onSuccess(response);
                        if (response.optInt("code") == 200){
                            onRefresh();
                        }else {
                            alert(response.optString("message"));
                        }
                    }
                });
            }
        });
    }

    public void bindChuZu(RecyclerViewHolder holder, int position, final MineRelease model) {
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        ((ExpandImageView) holder.getView(R.id.icon)).setImageURI(model.getThumb());
        holder.setText(R.id.title, model.getTitle());
        holder.setText(R.id.desc, model.getXiaoqu() + "|" + model.getShi() + "室" + model.getTing() + "厅" + model.getWei() + "卫" + "|" + model.getLeixing());
        holder.setText(R.id.money,model.getPrice() + "元/月");
        holder.setText(R.id.time, model.getPosttime());

        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/main/MainChuZuInfoRUI").withString("id", model.getNid()).navigation();
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                    @Override
                    public void onSuccess(JSONObject response) {
                        super.onSuccess(response);
                        if (response.optInt("code") == 200){
                            onRefresh();
                        }else {
                            alert(response.optString("message"));
                        }
                    }
                });
            }
        });
    }

    public void bindQiuZu(RecyclerViewHolder holder, int position, final MineRelease model) {
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        holder.setText(R.id.title, model.getTitle());
        holder.setText(R.id.desc, model.getAreaid() + "|" + model.getShi() + "室" + model.getTing() + "厅" + model.getWei() + "卫" + "|" + model.getLeixing());
        holder.setText(R.id.time, model.getPosttime());

        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/main/MainQiuZuInfoUI").withString("id", model.getNid()).navigation();
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                    @Override
                    public void onSuccess(JSONObject response) {
                        super.onSuccess(response);
                        if (response.optInt("code") == 200){
                            onRefresh();
                        }else {
                            alert(response.optString("message"));
                        }
                    }
                });
            }
        });
    }

    public void bindChuShou(RecyclerViewHolder holder, int position, final MineRelease model) {
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        ((ExpandImageView) holder.getView(R.id.icon)).setImageURI(model.getThumb());
        holder.setText(R.id.title, model.getTitle());
        holder.setText(R.id.time, model.getPosttime());

        holder.setText(R.id.desc, model.getXiaoqu() + "|" + model.getShi() + "室" + model.getTing() + "厅" + model.getWei() + "卫" + "|" + model.getMianji() + "m²");
        holder.setText(R.id.money,model.getPrice() + "万");
        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/main/MainChuShouInfoRUI").withString("id", model.getNid()).navigation();
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                    @Override
                    public void onSuccess(JSONObject response) {
                        super.onSuccess(response);
                        if (response.optInt("code") == 200){
                            onRefresh();
                        }else {
                            alert(response.optString("message"));
                        }
                    }
                });
            }
        });
    }

    public void bindQiuGou(RecyclerViewHolder holder, int position, final MineRelease model) {
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        holder.setText(R.id.title, model.getTitle());
        holder.setText(R.id.time, model.getPosttime());

        holder.setText(R.id.desc, model.getAreaid() + "|" + model.getShi() + "室" + model.getTing() + "厅" + model.getWei() + "卫");
        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/main/MainQiuGouInfoUI").withString("id", model.getNid()).navigation();
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                    @Override
                    public void onSuccess(JSONObject response) {
                        super.onSuccess(response);
                        if (response.optInt("code") == 200){
                            onRefresh();
                        }else {
                            alert(response.optString("message"));
                        }
                    }
                });
            }
        });
    }

    public void bindZhuanRang(RecyclerViewHolder holder, int position, final MineRelease model) {
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        holder.setText(R.id.title, model.getTitle());
        holder.setText(R.id.time, model.getPosttime());

        holder.setText(R.id.desc,model.getAreaid() + "|" + model.getMianji() + "㎡");
        holder.setText(R.id.money, model.getZujin() + "元/月");
        ((ExpandImageView) holder.getView(R.id.icon)).setImageURI(model.getThumb());
        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/main/MainZhuanRangInfoUI").withString("id", model.getNid()).navigation();
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                    @Override
                    public void onSuccess(JSONObject response) {
                        super.onSuccess(response);
                        if (response.optInt("code") == 200){
                            onRefresh();
                        }else {
                            alert(response.optString("message"));
                        }
                    }
                });
            }
        });
    }

    public void bindErShou(RecyclerViewHolder holder, int position, final MineRelease model) {
        TextView shenhe = holder.itemView.findViewById(R.id.shenhe);
        Button delete = holder.itemView.findViewById(R.id.delete);
        if (model.getStatus_name() != null && model.getStatus_name().length()>0){
            shenhe.setText(model.getStatus_name());
            switch (model.getStatus_name()){
                case "待审核":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.INVISIBLE);
                    break;
                case "审核通过":
                    shenhe.setTextColor(getResources().getColor(R.color.base_title_color));
                    delete.setVisibility(View.VISIBLE);
                    break;
                case "审核不通过":
                    shenhe.setTextColor(getResources().getColor(R.color.red));
                    delete.setVisibility(View.VISIBLE);
                    break;
            }
        }
        if (model.getType().equals("1")){
            ((ExpandImageView) holder.getView(R.id.icon)).setImageURI(model.getThumb());
            ((ExpandImageView) holder.getView(R.id.icon)).setVisibility(View.VISIBLE);
        }else {
            ((ExpandImageView) holder.getView(R.id.icon)).setVisibility(View.GONE);
        }

        holder.setText(R.id.title, model.getTitle());
        String type = model.getType().equals("1")?"出售":"求购";
        holder.setText(R.id.desc, model.getAreaid() + "|" + type);
        holder.setText(R.id.time, model.getPosttime());

        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (model.getType()){
                    case "1":
                        ARouter.getInstance().build("/main/MainErShouChuShouInfoUI").withString("id", model.getNid()).navigation();
                        break;
                    case "2":
                        ARouter.getInstance().build("/main/MainErShouQiuGouInfoUI").withString("id", model.getNid()).navigation();
                        break;
                }
            }
        });

        final JSONObject params = new JSONObject();
        try {
            params.put("type", getArguments().getInt("type"));
            params.put("id", model.getNid());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new XDialog2Button(getActivity()).setMsg("删除\n\n确定要删除该发布信息？").setCallback(new XDialog2Button.XDialog2ButtonCallBack() {
                    @Override
                    public void confirm() {
                        BaseHttp.getInstance().query("Me/deleteInfo", params, new HttpCallBack() {
                            @Override
                            public void onSuccess(JSONObject response) {
                                super.onSuccess(response);
                                if (response.optInt("code") == 200){
                                    onRefresh();
                                }else {
                                    alert(response.optString("message"));
                                }
                            }
                        });
                    }
                    @Override
                    public void cancel() {}
                }).show();
            }
        });
    }

}
